package com.laf.interceptor;

import com.laf.model.Userinfo;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: He Changjie  on  2018-10-02
 * @description:
 */
public class MainIterceptor extends HandlerInterceptorAdapter  {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Userinfo logUser = (Userinfo) request.getSession().getAttribute("logUser");
        if(logUser!=null){
            return true;
        }
        response.sendRedirect(request.getContextPath()+"/views/laf-login.jsp");
        return false;
    }
}
